package com.fone.player.entity;

import java.util.ArrayList;
import java.util.List;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * 
 * 播放记录
 * 
 * @author wangyang
 * @since 2014年5月14日
 */
public class PlayRecord implements Parcelable {
	/**
	 * 播放器-本地视频
	 */
	public static final int RECORD_PLAYER_LOCAL = 0;
	/**
	 * 播放器-网络视频
	 */
	public static final int RECORD_PLAYER_NETWORK = 1;
	/**
	 * 网页-网络视频(输入地址播放)
	 */
	public static final int RECORD_WEB_NETWORK = 2;
	/**
	 * 播放器-离线缓存视频
	 */
	public static final int RECORD_PLAYER_CACHE = 3;
	/**
	 * 网页-源网页
	 */
	public static final int RECORD_WEB_SOURCE = 4;
	/**
	 * 网页所有视频(仅查询使用)(表示RECORD_PLAYER_NETWORK和RECORD_WEB_SOURCE组合)
	 */
	public static final int RECORD_WEB_ALL = 5;
	/**
	 * 已同步,收藏同步标记
	 */
	public final static int PLAY_RECORD_SYNCHRONZIE_ADD_ALREADY = 0;
	/**
	 * 待同步,收藏同步标记
	 */
	public final static int PLAY_RECORD_SYNCHRONZIE_ADD_WAIT = 1;
	/**
	 * 待删除,收藏同步标记
	 */
	public final static int PLAY_RECORD_SYNCHRONZIE_DELETE_WAIT = 2;
	/**
	 * 获取所有收藏
	 */
	public final static int PLAY_RECORD_SYNCHRONZIE_ALL = 3;
	/**
	 * 获取所有未同步的
	 */
	public final static int PLAY_RECORD_SYNCHRONZIE_ALL_WAIT = 4;
	// 播放记录条目id
	private long mPlayRecordId;
	// 内容ID
	private long mPlayRecordCID;
	// 内容集合ID
	private long mPlayRecordCCID;
	// 栏目ID
	private long mPlayRecordCLID;
	// 片库ID
	private long mPlayRecordVideoID;
	// 播放记录类型(0播放器-本地视频,1播放器-网络视频2网页-网络视频)
	private int mPlayRecordType;
	// 节目内容类型
	private int mPlayRecordContentType;
	// 节目名称
	private String mPlayRecordName;
	// 节目缩略图路径
	private String mPlayRecordImageUrl;
	// 节目播放地址
	private String mPlayRecordPlayUrl;
	// 节目已经播放的位置
	private long mPlayRecordAlreadyPlayTime;
	// 节目时长
	private long mPlayRecordTotalTime;
	// 播放记录创建的时间
	private long mPlayRecordCreateTime;
	// 是否是vip
	private boolean mPlayRecordIsVIP;
	// 记录描述
	private String mPlayRecordDescription;
	// 服务器删除播放记录时的请求地址
	private String mPlayRecordRemoveUrl;
	// 服务器收藏视频时的请求地址
	private String mPlayRecordFavouriteUrl;
	// 小屏播放时的请求地址
	private String mPlayRecordDetailUrl;
	// 分享时的请求地址
	private String mPlayRecordShareUrl;
	// 播放记录同步状态
	private int mPlayRecordSynchronzieType;
	// 节目最新片段(更新至1集或1季)
	private String mPlayRecordEpisodeUpdateInfo;
	// 节目外部连接(ourl)
	private String mPlayRecordExternalUrl;
	// 是否显示播放按钮( 0不显示, 1显示(默认))(btnply)
	private boolean mPlayRecordIsShowPlayButton;
	// 视频分片集合(只有离线缓存和边播边下时内部使用,其他模块不用关系此集合)
	private List<OfflineCacheFragment> mOfflineCacheFragmentList = new ArrayList<OfflineCacheFragment>();

	@Override
	public void writeToParcel(Parcel out, int flags) {
		out.writeLong(mPlayRecordId);
		out.writeLong(mPlayRecordCID);
		out.writeLong(mPlayRecordCCID);
		out.writeLong(mPlayRecordCLID);
		out.writeLong(mPlayRecordVideoID);
		out.writeInt(mPlayRecordType);
		out.writeInt(mPlayRecordContentType);
		out.writeString(mPlayRecordName);
		out.writeString(mPlayRecordImageUrl);
		out.writeString(mPlayRecordPlayUrl);
		out.writeLong(mPlayRecordAlreadyPlayTime);
		out.writeLong(mPlayRecordTotalTime);
		out.writeLong(mPlayRecordCreateTime);
		out.writeInt(mPlayRecordIsVIP ? 1 : 0);
		out.writeString(mPlayRecordDescription);
		out.writeString(mPlayRecordRemoveUrl);
		out.writeString(mPlayRecordFavouriteUrl);
		out.writeString(mPlayRecordDetailUrl);
		out.writeString(mPlayRecordShareUrl);
		out.writeString(mPlayRecordEpisodeUpdateInfo);
		out.writeInt(mPlayRecordSynchronzieType);
		out.writeString(mPlayRecordExternalUrl);
		out.writeInt(mPlayRecordIsShowPlayButton ? 1 : 0);
	}

	public static final Parcelable.Creator<PlayRecord> CREATOR = new Parcelable.Creator<PlayRecord>() {
		public PlayRecord createFromParcel(Parcel in) {
			return new PlayRecord(in);
		}

		public PlayRecord[] newArray(int size) {
			return new PlayRecord[size];
		}
	};

	private PlayRecord(Parcel in) {
		mPlayRecordId = in.readLong();
		mPlayRecordCID = in.readLong();
		mPlayRecordCCID = in.readLong();
		mPlayRecordCLID = in.readLong();
		mPlayRecordVideoID = in.readLong();
		mPlayRecordType = in.readInt();
		mPlayRecordContentType = in.readInt();
		mPlayRecordName = in.readString();
		mPlayRecordImageUrl = in.readString();
		mPlayRecordPlayUrl = in.readString();
		mPlayRecordAlreadyPlayTime = in.readLong();
		mPlayRecordTotalTime = in.readLong();
		mPlayRecordCreateTime = in.readLong();
		mPlayRecordIsVIP = in.readInt() == 1;
		mPlayRecordDescription = in.readString();
		mPlayRecordRemoveUrl = in.readString();
		mPlayRecordFavouriteUrl = in.readString();
		mPlayRecordDetailUrl = in.readString();
		mPlayRecordShareUrl = in.readString();
		mPlayRecordEpisodeUpdateInfo = in.readString();
		mPlayRecordSynchronzieType = in.readInt();
		mPlayRecordExternalUrl = in.readString();
		mPlayRecordIsShowPlayButton = in.readInt() == 1;
	}

	public String getPlayRecordExternalUrl() {
		return mPlayRecordExternalUrl == null ? "" : mPlayRecordExternalUrl;
	}

	public void setPlayRecordExternalUrl(String playRecordExternalUrl) {

		mPlayRecordExternalUrl = playRecordExternalUrl;
	}

	public boolean getPlayRecordIsShowPlayButton() {
		return mPlayRecordIsShowPlayButton;
	}

	public void setPlayRecordIsShowPlayButton(boolean playRecordIsShowPlayButton) {

		mPlayRecordIsShowPlayButton = playRecordIsShowPlayButton;
	}

	/**
	 * 
	 * 获取url数组
	 * 
	 * @return String[]
	 */
	public String[] getOfflineCacheFragmentUrlArray() {
		String[] urlArray = new String[mOfflineCacheFragmentList.size()];
		for (int i = 0; i < mOfflineCacheFragmentList.size(); i++) {
			OfflineCacheFragment offlineCacheFragment = mOfflineCacheFragmentList
					.get(i);
			urlArray[i] = offlineCacheFragment.getCacheFragmentUrl();
		}

		return urlArray;
	}

	/**
	 * 
	 * 获取时长数组
	 * 
	 * @return String[]
	 */
	public int[] getOfflineCacheFragmentDurationArray() {
		int[] durationArray = new int[mOfflineCacheFragmentList.size()];
		for (int i = 0; i < mOfflineCacheFragmentList.size(); i++) {
			OfflineCacheFragment offlineCacheFragment = mOfflineCacheFragmentList
					.get(i);
			durationArray[i] = (int) offlineCacheFragment.getCacheDuration();
		}
		return durationArray;
	}

	public List<OfflineCacheFragment> getOfflineCacheFragmentList() {
		return mOfflineCacheFragmentList;
	}

	public void setOfflineCacheFragmentList(
			List<OfflineCacheFragment> offlineCacheFragmentList) {
		mOfflineCacheFragmentList = offlineCacheFragmentList;
	}

	public void addOfflineCacheFragment(
			OfflineCacheFragment offlineCacheFragment) {
		mOfflineCacheFragmentList.add(offlineCacheFragment);
	}

	public String getPlayRecordEpisodeUpdateInfo() {
		return mPlayRecordEpisodeUpdateInfo == null ? ""
				: mPlayRecordEpisodeUpdateInfo;
	}

	public void setPlayRecordEpisodeUpdateInfo(
			String playRecordEpisodeUpdateInfo) {

		mPlayRecordEpisodeUpdateInfo = playRecordEpisodeUpdateInfo;
	}

	/**
	 * 
	 * 获取播放记录同步标记
	 * 
	 * 
	 * @return int 播放记录同步标记<br>
	 *         PlayRecord.PLAY_RECORD_SYNCHRONZIE_ADD_ALREADY 已同步<br>
	 *         PlayRecord.PLAY_RECORD_SYNCHRONZIE_ADD_WAIT 待添加<br>
	 *         PlayRecord.PLAY_RECORD_SYNCHRONZIE_DELETE_WAIT 待删除<br>
	 */
	public int getPlayRecordSynchronzieType() {
		return mPlayRecordSynchronzieType;
	}

	/**
	 * 
	 * 设置播放记录同步标记
	 * 
	 * 
	 * @return int 播放记录同步标记<br>
	 *         PlayRecord.PLAY_RECORD_SYNCHRONZIE_ADD_ALREADY 已同步<br>
	 *         PlayRecord.PLAY_RECORD_SYNCHRONZIE_ADD_WAIT 待添加<br>
	 *         PlayRecord.PLAY_RECORD_SYNCHRONZIE_DELETE_WAIT 待删除<br>
	 */
	public void setPlayRecordSynchronzieType(int playRecordSynchronzieType) {

		mPlayRecordSynchronzieType = playRecordSynchronzieType;
	}

	public long getPlayRecordCID() {
		return mPlayRecordCID;
	}

	public void setPlayRecordCID(long playRecordCID) {

		mPlayRecordCID = playRecordCID;
	}

	public long getPlayRecordCCID() {
		return mPlayRecordCCID;
	}

	public void setPlayRecordCCID(long playRecordCCID) {

		mPlayRecordCCID = playRecordCCID;
	}

	public long getPlayRecordCLID() {
		return mPlayRecordCLID;
	}

	public void setPlayRecordCLID(long playRecordCLID) {

		mPlayRecordCLID = playRecordCLID;
	}

	public long getPlayRecordVideoID() {
		return mPlayRecordVideoID;
	}

	public void setPlayRecordVideoID(long playRecordVideoID) {

		mPlayRecordVideoID = playRecordVideoID;
	}

	/**
	 * 
	 * 获取缓存内容类型
	 * 
	 * 
	 * @return int 缓存内容类型<br>
	 *         OfflineCache.CACHE_CONTENT_TYPE_ALL 全部<br>
	 *         OfflineCache.CACHE_CONTENT_TYPE_MOVIE 电影<br>
	 *         OfflineCache.CACHE_CONTENT_TYPE_TV 电视剧<br>
	 *         OfflineCache.CACHE_CONTENT_TYPE_ANIMATION 动漫<br>
	 *         OfflineCache.CACHE_CONTENT_TYPE_VARIETY 综艺<br>
	 *         OfflineCache.CACHE_CONTENT_TYPE_ORIGINAL 原创<br>
	 *         OfflineCache.CACHE_CONTENT_TYPE_LIVE_VIDEO 视频直播<br>
	 *         OfflineCache.CACHE_CONTENT_TYPE_LIVE_AUDIO 音频直播<br>
	 *         OfflineCache.CACHE_CONTENT_TYPE_NEWS 新闻<br>
	 *         OfflineCache.CACHE_CONTENT_TYPE_SHORT_FILM 短片<br>
	 *         OfflineCache.CACHE_CONTENT_TYPE_WEB_PAGE 网页<br>
	 */
	public int getPlayRecordContentType() {
		return mPlayRecordContentType;
	}

	/**
	 * 
	 * 设置缓存内容类型
	 * 
	 * @param playRecordContentType
	 *            缓存内容类型<br>
	 *            来自服务器的favtyp字段
	 * @return void
	 */
	public void setPlayRecordContentType(int playRecordContentType) {

		mPlayRecordContentType = playRecordContentType;
	}

	public String getPlayRecordRemoveUrl() {
		return mPlayRecordRemoveUrl == null ? "" : mPlayRecordRemoveUrl;
	}

	public void setPlayRecordRemoveUrl(String playRecordRemoveUrl) {

		mPlayRecordRemoveUrl = playRecordRemoveUrl;
	}

	public String getPlayRecordDetailUrl() {
		return mPlayRecordDetailUrl == null ? "" : mPlayRecordDetailUrl;
	}

	public void setPlayRecordDetailUrl(String playRecordDetailUrl) {

		mPlayRecordDetailUrl = playRecordDetailUrl;
	}

	public String getPlayRecordShareUrl() {
		return mPlayRecordShareUrl == null ? "" : mPlayRecordShareUrl;
	}

	public void setPlayRecordShareUrl(String playRecordShareUrl) {

		mPlayRecordShareUrl = playRecordShareUrl;
	}

	public String getPlayRecordFavouriteUrl() {
		return mPlayRecordFavouriteUrl == null ? "" : mPlayRecordFavouriteUrl;
	}

	public void setPlayRecordFavouriteUrl(String playRecordFavouriteUrl) {

		mPlayRecordFavouriteUrl = playRecordFavouriteUrl;
	}

	public long getPlayRecordId() {
		return mPlayRecordId;
	}

	public void setPlayRecordId(long playRecordId) {

		mPlayRecordId = playRecordId;
	}

	/**
	 * 
	 * 获取播放记录类型
	 * 
	 * 
	 * @return int 播放记录类型<br>
	 *         PlayRecord.RECORD_PLAYER_LOCAL 播放器-本地视频<br>
	 *         PlayRecord.RECORD_PLAYER_NETWORK 播放器-网络视频<br>
	 *         PlayRecord.RECORD_WEB_NETWORK 网页-网络视频<br>
	 */
	public int getPlayRecordType() {
		return mPlayRecordType;
	}

	/**
	 * 
	 * 设置播放记录类型
	 * 
	 * @param cacheContentType
	 *            播放记录类型<br>
	 *            PlayRecord.RECORD_PLAYER_LOCAL 播放器-本地视频<br>
	 *            PlayRecord.RECORD_PLAYER_NETWORK 播放器-网络视频<br>
	 *            PlayRecord.RECORD_WEB_NETWORK 网页-网络视频<br>
	 * @return void
	 */
	public void setPlayRecordType(int playRecordType) {

		mPlayRecordType = playRecordType;
	}

	public String getPlayRecordName() {
		return mPlayRecordName == null ? "" : mPlayRecordName;
	}

	public void setPlayRecordName(String playRecordName) {

		mPlayRecordName = playRecordName;
	}

	public String getPlayRecordImageUrl() {
		return mPlayRecordImageUrl == null ? "" : mPlayRecordImageUrl;
	}

	public void setPlayRecordImageUrl(String playRecordImageUrl) {

		mPlayRecordImageUrl = playRecordImageUrl;
	}

	public String getPlayRecordPlayUrl() {
		return mPlayRecordPlayUrl == null ? "" : mPlayRecordPlayUrl;
	}

	public void setPlayRecordPlayUrl(String playRecordPlayUrl) {

		mPlayRecordPlayUrl = playRecordPlayUrl;
	}

	public long getPlayRecordAlreadyPlayTime() {
		return mPlayRecordAlreadyPlayTime;
	}

	public void setPlayRecordAlreadyPlayTime(long playRecordAlreadyPlayTime) {

		mPlayRecordAlreadyPlayTime = playRecordAlreadyPlayTime;
	}

	public long getPlayRecordTotalTime() {
		return mPlayRecordTotalTime;
	}

	public void setPlayRecordTotalTime(long playRecordTotalTime) {

		mPlayRecordTotalTime = playRecordTotalTime;
	}

	public long getPlayRecordCreateTime() {
		return mPlayRecordCreateTime;
	}

	public void setPlayRecordCreateTime(long playRecordCreateTime) {

		mPlayRecordCreateTime = playRecordCreateTime;
	}

	public boolean getPlayRecordIsVIP() {
		return mPlayRecordIsVIP;
	}

	public void setPlayRecordIsVIP(boolean isVIP) {

		mPlayRecordIsVIP = isVIP;
	}

	public String getPlayRecordDescription() {
		return mPlayRecordDescription == null ? "" : mPlayRecordDescription;
	}

	public void setPlayRecordDescription(String playRecordDescription) {

		mPlayRecordDescription = playRecordDescription;
	}

	public PlayRecord() {

	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public String toString() {
		return "PlayRecord [mPlayRecordId=" + mPlayRecordId
				+ ", mPlayRecordCID=" + mPlayRecordCID + ", mPlayRecordCCID="
				+ mPlayRecordCCID + ", mPlayRecordCLID=" + mPlayRecordCLID
				+ ", mPlayRecordVideoID=" + mPlayRecordVideoID
				+ ", mPlayRecordType=" + mPlayRecordType
				+ ", mPlayRecordContentType=" + mPlayRecordContentType
				+ ", mPlayRecordName=" + mPlayRecordName
				+ ", mPlayRecordImageUrl=" + mPlayRecordImageUrl
				+ ", mPlayRecordPlayUrl=" + mPlayRecordPlayUrl
				+ ", mPlayRecordAlreadyPlayTime=" + mPlayRecordAlreadyPlayTime
				+ ", mPlayRecordTotalTime=" + mPlayRecordTotalTime
				+ ", mPlayRecordCreateTime=" + mPlayRecordCreateTime
				+ ", mPlayRecordIsVIP=" + mPlayRecordIsVIP
				+ ", mPlayRecordDescription=" + mPlayRecordDescription
				+ ", mPlayRecordRemoveUrl=" + mPlayRecordRemoveUrl
				+ ", mPlayRecordFavouriteUrl=" + mPlayRecordFavouriteUrl
				+ ", mPlayRecordDetailUrl=" + mPlayRecordDetailUrl
				+ ", mPlayRecordShareUrl=" + mPlayRecordShareUrl
				+ ", mPlayRecordSynchronzieType=" + mPlayRecordSynchronzieType
				+ ", mPlayRecordEpisodeUpdateInfo="
				+ mPlayRecordEpisodeUpdateInfo + "]";
	}

}
